/**
 * @file    inf_cps121.h
 * @author  yhy
 * @brief   CPS121传感器头文件
 * @version 1.01
 * @date    2025-07-19
 *
 * @copyright Copyright (c) 2025
 *
 * @details
 * Change Logs:
 * Date           Author       Notes
 * 2025-07-19     yhy          the first version V1.00
 * 2025-10-22     yhy          修复了11个传感器只初始化了9个的问题 V1.01
 *
 */
#ifndef __INF_CPS121_H__
#define __INF_CPS121_H__

#include "common_config.h"

#include <stdint.h>

/**
 * @brief CPS121传感器索引枚举
 *
 */
typedef enum
{
    CPS121_IDX_0  = 0U,
    CPS121_IDX_1  = 1U,
    CPS121_IDX_2  = 2U,
    CPS121_IDX_3  = 3U,
    CPS121_IDX_4  = 4U,
    CPS121_IDX_5  = 5U,
    CPS121_IDX_6  = 6U,
    CPS121_IDX_7  = 7U,
    CPS121_IDX_8  = 8U,
    CPS121_IDX_9  = 9U,
    CPS121_IDX_10 = 10U,
    CPS121_IDX_MAX,
} cps121_idx_e;

/**
 * @brief 传感器状态枚举
 *
 */
typedef enum
{
    CPS121_STATE_IDLE = 0U, /*!< 传感器处于空闲状态 */
    CPS121_STATE_BUSY = 1U, /*!< 传感器处于忙状态, 即正在读取数据 */
} cps121_state_e;

/**
 * @brief CPS121传感器结构体
 *
 */
typedef struct
{
    cps121_idx_e   sensor_idx;   /*<! 传感器索引, 用于区分多个CPS121传感器 */
    uint32_t       air_pressure; /*<! 气压值 */
    cps121_state_e state;        /*<! 传感器当前状态 */
} cps121_sensor_t;

extern cps121_sensor_t cps121_sensor_list[CPS121_IDX_MAX];

result_e inf_cps121_init(void);
void     inf_cps121_update_air_pressure(void);

#endif
